#ifndef __M_CHEAT_LIST_H__
#define __M_CHEAT_LIST_H__

#include <stdint.h>

#include "linked_list.h"
#include "file.h"

typedef struct CheatCode // "无限能量;82E2:03;81E1:10; ..."
{                        // "name;address:value;address:value;..."
    uint32_t address;    // "02001234" 地址    (十六进制)
    uint32_t value;      // "01"       设置值  (十六进制)
    uint32_t bytes;      // "1"        字节数  (由value长度判断)
    uint32_t mask;       // "FF"       值掩码  (十六进制)
} CheatCode;

typedef struct CheatValue
{
    char *label;
    char *native;
    CheatCode *codes;
    int n_codes;
    int max_times;
} CheatValue;

typedef struct CheatEntryData
{
    char *desc;       // "无限血量"  名称
    uint32_t handler; // "1"        类型：  0 核心金手指，1 前端金手指
    uint32_t endian;  // "0"        大小端：0 小端，1 大端
    uint32_t select;
    uint32_t old_select;
    int cur_times;
    CheatValue *values;
    int n_values;
} CheatEntryData;

int CheatListGetEntriesFromBuffer(LinkedList *list, void *buffer, int size);
int CheatListGetEntries(LinkedList *list, const char *path);
LinkedList *NewCheatList();

int CheatListUpdateConfig(LinkedList *list);
int CheatListResetConfig(LinkedList *list);
int CheatListLoadConfig(LinkedList *list, const char *path);
int CheatListSaveConfig(LinkedList *list, const char *path);

#endif